<!-- Sofija Puric 6/08 -->
<?php
    require '../../pages/db.php';
    $con=dbConnect("sib");

    $name=$_POST["name"];
    $location=$_POST["location"];
    $date_from=$_POST["date_from"];
    $date_to=$_POST["date_to"];
    $brief=$_POST["brief"];
    $full=$_POST["full"];
    $link=$_POST["link"];
    $url=$_POST["url"];
    $alt=$_POST["alt"];

    function change_format_date($date) {
    $new = explode('/',$date);
    $day = $new[0]; $month = $new[1]; $year= $new[2];
    $d = $year.'-'.$month.'-'.$day;
    return $d;
}
    $from = change_format_date($date_from);
    $to = change_format_date($date_to);

    $timest = mktime(date("H") + 2, date("i"), date("s"), date("m"), date("d"), date("Y"));
    $today = date("Y-m-d H:i:s", $timest);

    if ($name=="" || $location=="" || $date_from=="" || $date_to=="" || $brief=="" || $full=="" || 
            $link=="" || $url=="" || $alt=="")
    {
        echo '<div id="error">ERROR: You must fill in all the gaps!<div/>';

    }
    else{
        $sql="INSERT INTO event(Name, Location, DateFrom, DateTo, BriefDescription, FullDescription, CreationDate, Link, Url, Alt)
            VALUES('$name', '$location', '$from', '$to', '$brief', '$full', '$today', '$link', '$url', '$alt')";
         if (!mysql_query($sql, $con)) {
             die('Error: ' . mysql_error());
         }
         else {
             header('Location: ../events-admin.php'); // treba da se pojavi event na ovoj stranici!!!

         }

    }
    mysql_close($con);
?>
